<!--
/**************************************************
* @(#)orderinput.jsp
*
* Copyright (c) 2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/02/08, SimonyiPeng
*  1) first release
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.*"%>
<%@ include file="../../common.jsp" %>
<%@page import="system.LoginContext"%>
<%@page import="system.base.Warehouse"%>
<%@page import="system.base.ProductStorage"%>
<html>
<head>
<title>生成订单</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/calendar2.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/string.js"></SCRIPT>
</head>

<%
	
	boolean isChange = true;
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String strSysDate = sdf.format(new Date(System.currentTimeMillis()));	 
	
    GSBalanceParamDAO dao = new GSBalanceParamDAO();
    GSBalanceParamBean tBean = new GSBalanceParamBean();
    tBean = dao.queryBalanceDate();
   
    String strEnd = tBean.getGs_balance_end_date();    
    int intEnd = 0;
    
    String strStart = tBean.getGs_balance_start_date();
    
    int intNowDay = Integer.parseInt(strSysDate.substring(8,10));
    
    int intMonthMax = DateUtil.getMaxMonthDay(strSysDate);
    
    if (strEnd.length()==1) strEnd = "0" + strEnd;
	
	if (tBean.getGs_balance_date_type().equals("1"))
	{
		strEnd = DateUtil.getMaxMonthDay(strSysDate) + "";
		strStart = "1";
	}
	
	intEnd = Integer.parseInt(strEnd);
	
	if (intEnd< intNowDay && intNowDay < intMonthMax)
	{
		isChange = true;
	}
	else
	{
		isChange = false;
	}	
	
	String strFinanceEndDate = strSysDate.substring(0,8) + strEnd;
	
	ArrayList bcList = (ArrayList)request.getAttribute("balancecategory");
	Warehouse ware = (Warehouse)request.getAttribute("ware");
	
	//配送方式
	ArrayList deliverModeList = (ArrayList)request.getAttribute("deliverModeList");
	if (deliverModeList == null) deliverModeList = new ArrayList();
	
	//结算方式
	ArrayList balanceModeList = (ArrayList)request.getAttribute("balanceModeList");
	if (balanceModeList == null) balanceModeList = new ArrayList();
	//产品及供应商
    ArrayList mList=(ArrayList)request.getAttribute("manufacture");
    
    //送货地址
    ArrayList deptList=(ArrayList)request.getAttribute("orderdept");
	//备注字段长度
	int memoLen = 800;

%>


<script language='javascript'>

	<%
		//如果点击"保存并新增"按钮，在此作出保存成功提示
		if(request.getAttribute("SUCCESSMSG") != null)
			out.print("alert('"+request.getAttribute("SUCCESSMSG")+"');");
	%>
	
	function submitForm(){
				document.form1.action='<%=response.encodeURL(root+"/A100111.do")%>';
				form1.submit();
	}
	
	function checkNoneableValue(){	
		var currentrownum = document.getElementById('currentrownum').value;
		var deptid = document.getElementById("deptid").value;
        var deliveraddr = document.getElementById("deliveraddr").value;
		var delivermode = document.getElementById("delivermode").value;
		var delivermode_ = document.getElementById("delivermode_").value;
		var balancemode = document.getElementById("balancemode").value;
		var balancemode_ = document.getElementById("balancemode_").value;
		var balancecategory = document.getElementsByName("balancecategory");
		var checkedBC = null;

		for(i=0;i<balancecategory.length;i++){
			if(balancecategory[i].checked){
				checkedBC = balancecategory[i].value;
			}
		}
		
		var linkm = document.getElementById("linkman_").value;
		var linkt = document.getElementById("linktel_").value;
		if(deptid == null || deptid == "") {
			alert("请确认订货单位已经选择");return false;
		}	
        if(deliveraddr == null || deliveraddr == ""){
            alert("请确认送货地址已经选择");   return false;
        }   
		if(delivermode == '2' && delivermode_ == ""){
			alert("请确认配送方式已经选择");	return false;
		}
		if(balancemode == '2' && balancemode_ == ""){
			alert("请确认结算方式已经选择");	return false;
		}
		if(checkedBC == null){
			alert("请确认结算分类已经选择");return false;
		}
		
		var sum = 0;
		for(i=1;i<=<%=mList.size()%>;i++)
		{
			var concentricityid = document.getElementById("concentricityid"+i).value;
			var ordercount = document.getElementById("ordercount"+i).value;
			var manufactureid = document.getElementById("manufactureid"+i).value;
			var deliverdate = document.getElementById("deliverdate"+i).value;
			var providerid = document.getElementById("providerid"+i).value;
			
			if(concentricityid != null && concentricityid != "") {
				if(manufactureid == null || manufactureid == ""){
					alert("请确认输入集中编码后已经选定产品");	
					return false;
				}
				if(providerid == null || providerid == ""){
					alert("请确认供应商已经选定");	
					return false;
				}
				if(ordercount == null || ordercount == "")
				{
					alert("请确认订货数量已经输入");	
					return false;
				}
				if(!isFloatNum(ordercount))
				{
					alert("请确认输入的订货数量为数字");	
					return false;
				}
				else
				{
					if(ordercount<=0) 
					{
						alert("订货数量必须大于0");
						return false;
					}
				}
				if(deliverdate == null || deliverdate == "")
				{
					alert("请确认送货日期已经输入");	
					return false;
				}
				
			}
			else{
				resetrow(i);
				sum = sum + i;
			}
		}	
		if(sum == 55){
			alert("申购单必须至少录入一条产品明细");
			return false;
		}		
		return true;
	}
	

	function jsfschange(){
		var val = document.getElementById('balancemode');
		for(var i=0; i<val.options.length; i++) {
			if(val.options[i].selected && val.options[i].value == "205") {
				if(confirm('是否确认手工输入结算方式?')){
					document.getElementById('balancemode_').style.display='';
					document.getElementById('balancemode').style.display='none';
				}else{
					alert("请重新选择结算方式");
					val.options[0].selected = true;
				}
			}
		}
	}

	function psfschange(){
		var val = document.getElementById('delivermode');
		for(var i=0; i<val.options.length; i++) {
			if(val.options[i].selected && val.options[i].value == "104") {
				if(confirm('是否确认手工输入配送方式?')){
					document.getElementById('delivermode_').style.display='';
					document.getElementById('delivermode').style.display='none';
				}else{
					alert("请重新选择配送方式");
					val.options[0].selected = true;
				}
			}
		}
	}	
	
	function checkconcentricityid(index)
	{
		if  (event.keyCode==13)
		{  
			if (checkiscontentricityidexist(index))
			{
				checkManufacture(index);
				keydown2("providerid"+index);
			}
			else
			{
				keydown2("ordercount"+index);
			}
		}		
	}
	
	function showMsg(balancecategoryno)
	{
	<%
		for(int bcs = 0;bcs < bcList.size();bcs++){
			GSBalanceCategoryBean bcBean = (GSBalanceCategoryBean)bcList.get(bcs);
	%>
			if(<%=bcBean.getGs_balance_category_no()%> == balancecategoryno){
				document.getElementById("bcName").value = '<%=bcBean.getGs_balance_category_name()%>';
			}
	<%		
		}
	%>
	}
function changeManufacture(rownum){
    
        var aaa = document.getElementById("providerid"+rownum).options;
        var selected = 0;
        for(i=0;i<aaa.length;i++){
            if(aaa[i].selected == true){
                selected = i;
            }
        }
        if(selected == 0) {
            document.getElementById("referenceprice"+rownum).innerHTML="";
        }
        var pricebuffer = document.getElementById("pricebuffer"+rownum).value;
        var a1 = tokenize(pricebuffer,"|");
        for(i=0;i<a1.length;i++){
            var a2 = tokenize(a1[i],":");
            if(selected == i+1){
            
                <%
                if (GSSystemConfigurator.getParam("gs.SetManufactureCode13").equalsIgnoreCase("true"))
                {
                %>
                    document.getElementById("concentricityid"+rownum).value = a2[2];
                    document.getElementById("manufactureid"+rownum).value = a2[3];
                <%
                }
                %>      
                document.getElementById("referenceprice"+rownum).innerHTML = a2[1];
                document.getElementById("balancemode"+rownum).innerText=a2[5];
                document.getElementById("mode"+rownum).value=a2[4];
                // add by Jackey start
                
                //计算合计 
                getMoney(rownum);
                
                // add by Jackey end
                return ;
            }
        }
        
        // add by Jackey start
        
        //计算合计
        getMoney(rownum);
        
        // add by Jackey end
    
    }
	function showCreateDate(val)
	{
		document.getElementById("createdate_").value = val;
	}
	function changeDeliverAddr(){
        var msg = document.getElementById('deliveraddr').value;
        if(msg!=""){
        var sz = StringTokenize(msg,'%',0,null);
        document.getElementById('linkman_').value=sz[2];
        document.getElementById('linktel_').value=sz[3];
        }
    }
</script>
<style type="text/css">
<!--
.mtxt_black {
	FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: #000000
}
-->
</style>
<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<input type='hidden' name='currmenu' value='1001'>
<center>

<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="20"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr height="20">
          <td height="20" width="2" class="mtxt_black">&nbsp;</td>
          <td height="30" width="558" class="mtxt_black" >库存生成订单</td>
          <td height="30" width="200">          
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bg_line" height="2"></td>
  </tr>
</table>

<br>


<form name="form1" id="form1" method="post"  style="visibility: visible;">
<input type='hidden' name='saveoption' value=''>
<input type='hidden'id='isChangeFalse' name='isChange' value='false'>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr> 
        <td> 
            <table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
                <tbody> 
                <tr class="bg_column" height=20> 
                    	<td align=middle colspan="11">订单总体信息</td>
                </tr>
                <tr class="bg_row_odd" height=20> 
                	<td class=top align=middle width='20%' id='aaa'>
                	    <div align="center" class="txt_content">订单编号</div>
                	</td>
                    <td class=top align=center id='bbb'> 
                        <div align="left" class="txt_content" style='display:none'> 
						<input type='text' id='orderid' name='orderid' size='9' maxlength='9'>
						</div>
						<div align=left class="txt_content" ><font color=#00309E">系统自动生成</font></div>
                    </td>
                    <td class=top align=middle> 
                        <div align="center" class="txt_content">结算分类</div>
                    </td>
                    <td class=top align=middle colspan='3'> 
                        <div align="left" class="txt_content"> 
                        <input type='hidden' name='bcName'>
                        <% 
                            
                            if(bcList == null){
                                out.print("<input type=radio name='balancecategory' value='0' checked onKeyDown='keydown2(\"Textarea1\");'>零部件&nbsp;");
                            }else{
                                for(int bcsize = 0;bcsize <bcList.size();bcsize++)
                                {
                                    GSBalanceCategoryBean bcBean = (GSBalanceCategoryBean)bcList.get(bcsize);
                                    if (bcList.size() == 1)
                                        out.print("<input type=radio onclick='showMsg("+bcBean.getGs_balance_category_no()+")' name='balancecategory' value="+bcBean.getGs_balance_category_no()+" checked onKeyDown='keydown2(\"Textarea1\");'>"+bcBean.getGs_balance_category_name()+"&nbsp;");
                                    else
                                        out.print("<input type=radio onclick='showMsg("+bcBean.getGs_balance_category_no()+")' name='balancecategory' value="+bcBean.getGs_balance_category_no()+" onKeyDown='keydown2(\"Textarea1\");'>"+bcBean.getGs_balance_category_name()+"&nbsp;");
                                }
                            }
                        %>
                        </div>
                    </td>
                </tr>
                
                <tr class="bg_row_odd" height=20> 
                    <td class=top align=middle> 
                        <div align="center" class="txt_content">订货单位</div>
                    </td>
                    <td class=top align="left"> <%=ware.getName() %>
                    <input type="hidden" name="deptid" value="<%=ware.getCode() %>">
                    </td>
	                <td class=top align=left> 
	                    <div align="center" class="txt_content">配送方式</div>
	                </td>
                    <td class=top align=middle > 
                        <div align='left' class='txt_content'> 
                        	<select id='delivermode' name='delivermode' onchange="psfschange();" onKeyDown="keydown2('balancemode')">
                        		<!--原
                        		<option value='1'>送货上门</option>
                        		<option value='2'>其他</option>
                        		-->
                        		<%
                        		//新修改
                        		for (int i=0;i<deliverModeList.size();i++)
                        		{
                        			GSDictionaryBean dictionary = (GSDictionaryBean) deliverModeList.get(i);
                        		%>	
                        			<option value="<%=dictionary.getId()%>"><%=dictionary.getName()%></option>
                        		<%	
                        		}
                        		%>
                        	</select><font color='red'>&nbsp;*</font>
                        </div>
	                    <div align='left' class='txt_content' > 
	                        <input type="text" id='delivermode_' name='delivermode_' size="8" value='' style='display:none'>
	                    </div>                        
                    </td>
	                <td class=top align=middle> 
	                    <div align="center" class="txt_content"  style="display:none;">结算方式</div>
	                </td>
                    <td class=top align=middle > 
                        <div align='left' class='txt_content' style="display:none;"> 
                        	<select id='balancemode' name='balancemode' onchange="jsfschange();"  style="width:160">
                        		<%
                        		//新修改
                        		for (int i=0;i<balanceModeList.size();i++)
                        		{
                        			GSDictionaryBean dictionary = (GSDictionaryBean) balanceModeList.get(i);
                        		%>	
                        			<option value="<%=dictionary.getId()%>"><%=dictionary.getName()%></option>
                        		<%	
                        		}
                        		%>                        		
                        	</select><font color='red'>&nbsp;*</font>
                        </div>
	                    <div align='left' class='txt_content' > 
	                        <input type="text" id='balancemode_' name='balancemode_' size="8" value='' style='display:none'>
	                    </div>
                    </td>

                </tr>
                                
                <tr class="bg_row_odd" height=20> 
	                <td class=top align=middle> 
	                    <div align="center" class="txt_content">送货地址</div>
	                </td>
                    <td class=top align=middle> 
                        <div align='left' class='txt_content'> 
                        <select name="deliveraddr" id='deliveraddr' onChange='changeDeliverAddr();'>
                        <%for(int j=0;j<deptList.size();j++){
                            GSWareHouseBean tmp=(GSWareHouseBean)deptList.get(j);
                            if(tmp.getAddress()!=null&&!"".equals(tmp.getAddress())){
                            %>
                            <option value="<%=tmp.getAddress() %>"><%=tmp.getAddress() %></option>
                            <%}} %>
                        </select>
                        	<font color='red'>&nbsp;*</font>
                        </div>
                    </td>
	                <td class=top align=middle> 
	                    <div align="center" class="txt_content">联系人</div>
	                </td>
                    
                    <td class=top align=middle nowrap id='linkman'> 
                        <div align='left' class='txt_content'> 
                        	<input type='text' id='linkman_' size='8' name='linkman_' value='<%=ware.getContactPerson() %>'>
                        </div>
                    </td>
	                <td class=top align=middle> 
	                    <div align="center" class="txt_content">联系电话</div>
	                </td>
                    
                    <td class=top align=middle nowrap id='linktel'> 
                        <div align='left' class='txt_content'> 
                        	<input type='text' id='linktel_' size='13' name='linktel_' value='<%=ware.getContackTel() %>'>
                        </div>
                    </td>                
                </tr>
                
                <tr class="bg_row_odd" height=20> 
                    <td class=top align=middle> 
                        <div align="center" class="txt_content">备注</div>
                    </td>
                    <td class=top align=middle colspan='5'> 
                        <div align="left" class="txt_content"> 
                        <textarea id="Textarea1" style="WIDTH: 100%; HEIGHT: 50px" name="notes"></textarea>
                        </div>
                    </td>
                </tr>
                
                </tbody> 
            </table>
        </td>
    </tr>
</table>

<center>




    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
    	<input type='hidden' id='currentrownum' name='currentrownum' value='<%=mList.size() %>'>
        <tr> 
            <td> 
                <table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
                    <tbody> 
                    <tr class="bg_column" height=20> 
                    	<td align=middle colspan="15">订单产品信息列表</td>
	                </tr>
	                
	                <tr class="bg_column" height=20> 
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 集中编码</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 产品名称</div>
                        </td>                        
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 规格</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 型号</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 品牌</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 质保期</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 供应商</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 价格（元）</div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 订货数量<font color='red'>&nbsp;*</font></div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 总价（元）</div>
                        </td>                        
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 单位</div>
                        </td>                        
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 送货日期<font color='red'>&nbsp;*</font></div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 送货时间<font color='red'>&nbsp;*</font></div>
                        </td>
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 结算模式</div>
                        </td>
                    </tr>

                    <% for(int i=0;i<mList.size();i++){
                           GSManufactureAndProvicerVo temp=(GSManufactureAndProvicerVo)mList.get(i);
                           GSManufactureBean mBean=temp.getManufactureBean();
                           ProductStorage storage=temp.getProductStorage();
                    %>
                    <tr id='tr<%=i+1 %>' class="bg_row_even" height=20 > 
					<input type='hidden' id='manufactureunitprice<%=i+1 %>' name='manufactureunitprice' value=''>
                        <!--集中编码-->
                        <td class=top align=middle nowrap>                         
                            <div align="center" class="txt_content"> 
                            <%= mBean.getGs_concentricity() %>
								<input type='hidden' id='concentricityid<%=i+1 %>' name='concentricityid' size='16' maxlength='20' value="<%= mBean.getGs_concentricity() %>">
								<input type='hidden' id='manufactureid<%=i+1 %>' name='manufactureid' size='7' maxlength='20' value="<%= mBean.getGs_manufacture_id() %>">
								<input type='hidden' id='manufacturename_<%=i+1 %>' value="<%=mBean.getGs_manufacture_name() %>">
								<input type='hidden' id='manufacturespec_<%=i+1 %>' value="<%= mBean.getGs_manufacture_spec() %>">
								<input type='hidden' id='manufacturetype_<%=i+1 %>' value="<%= mBean.getGs_manufacture_type() %>">
								<input type='hidden' id='manufacturebrand_<%=i+1 %>' value="<%= mBean.getGs_manufacture_brand() %>">
								<input type='hidden' id='manufactureunitprice_<%=i+1 %>' value="<%= mBean.getGs_manufacture_unitprice() %>">
								<input type='hidden' id='manufacturequantunit_<%=i+1 %>' value="<%=mBean.getGs_quant_unit() %>">
								<input type='hidden' id='period_<%=i+1 %>' value="<%= mBean.getGs_quality_assure_period() %>">							</div>
                        </td>
                        <!--产品名称-->
                        <td class=top align=middle nowrap>                         
                            <div align="center" class="txt_content" id='manufacturename<%=i+1 %>'> 
                                <%=mBean.getGs_manufacture_name() %>
							</div>
                        </td>
                        <!--规格-->
                        <td class=top align=middle nowrap>                         
                            <div align="center" id="spec<%=i+1 %>" class="txt_content">
                                <%=mBean.getGs_manufacture_spec() %>
							</div>
                        </td>
                        <!--型号-->
                        <td class=top align=middle nowrap>
                            <div align="center" id="type<%=i+1 %>" class="txt_content"> 
                            <%=mBean.getGs_manufacture_type() %>
							</div>
                        </td>
                        <!--品牌-->
                        <td class=top align=middle nowrap>                         
                            <div align="center" id="brand<%=i+1 %>" class="txt_content"> 
                            <%=mBean.getGs_manufacture_brand() %>
							</div>
                        </td>
                        <!--质保期-->
                        <td class=top align=middle nowrap>                         
                            <div align="center" id="period<%=i+1 %>" class="txt_content"> 
                            <%=mBean.getGs_quality_assure_period() %>
							</div>
                        </td>                        
                        <!--供应商-->
                        <%ArrayList providerList=temp.getProviderList(); %>
                        <td class=top align="left" nowrap> 
                            <div align="left" class="txt_content">
                            	<select id='providerid<%=i+1 %>' name='providerid' onChange="changeManufacture('<%=i+1 %>');">
									<%
									String pstr="";
									String storagePcode=storage.getProviderCode();
                                    for(int j=0;j<providerList.size();j++){
                                        String[] tStr=(String[])providerList.get(j);
                                        pstr+=tStr[0] + ":" +tStr[4] + ":" + tStr[2] + ":" + tStr[3] +":"+tStr[5]+":"+DefineDic.getBalanceMode(tStr[5])+"|";
                                        if(storagePcode.equals(tStr[0])){
                                    %>
                                    <option value="<%=tStr[0]  %>" selected="selected"><%=tStr[1] %></option>
                                    <%}else{ %>
                                    <option value="<%=tStr[0]  %>"><%=tStr[1] %></option>
                                    <%}} %>
                            	</select>
                            </div>
                        </td>

						<!--参考价格-->
						<input type="hidden" id='pricebuffer<%=i+1 %>' value='<%=pstr %>' >
                        <td class=top align=middle nowrap>                         
                            <div align="center" id="referenceprice<%=i+1 %>" class="txt_content"> 
                            <%=StringUtils.formatEDouble(mBean.getGs_manufacture_unitprice(),4) %>
							</div>
                        </td>
                        <!--订货数量-->
                        <td class=top align=middle> 
                            <div align="center" class="txt_content"> 
                            	<input type="text"  id='ordercount<%=i+1 %>' name='ordercount' size="8" maxlength="11" onblur="formatordercount(this)">
							</div>
                        </td>
                        <!--总价-->
                        <input type="hidden" id='moneybuffer<%=i+1 %>' value='0' >
                        <td class=top align=middle nowrap>                         
                            <div align="center" id="money<%=i+1 %>" class="txt_content">
							</div>
                        </td>                        
                        <!--单位-->
                        <td class=top align=middle nowrap>                         
                            <div align="center" id="quantunit<%=i+1 %>" class="txt_content">
                            <%=mBean.getGs_quant_unit() %>
							</div>
                        </td>                        
                        <!--送货日期-->
                        <td class=top align=middle nowrap> 
                            <div align="center" class="txt_content">                             	
                            	<input type="text" id='deliverdate<%=i+1 %>' name='deliverdate' size="12" value='<%=DateUtil.getTomorrow()%>' readonly onfocus='setday(this,document.getElementById("delivertime<%=i+1 %>"))'>

                            </div>
                        </td>
                        <!--送货时间-->
                        <td class=top align=middle> 
                            <div align='center' class='txt_content'> 
                            	<select id='delivertime<%=i+1 %>' name='delivertime'>
                            		<option value='1' <%=!GSSystemConfigurator.getProjectVersion().equalsIgnoreCase("SZ") ? "selected" : ""%>>8:00-12:00</option>
                            		<option value='2'>13:00-18:00</option>
                            		<option value='3' <%=GSSystemConfigurator.getProjectVersion().equalsIgnoreCase("SZ") ? "selected" : ""%>>全天</option>
                            	</select>
                            </div>
                        </td>
                        <!-- 结算模式 -->
                        <td class=top align=middle nowrap>                         
                            <div align="center" id="balancemode<%=i+1 %>" class="txt_content"> 
                            <%=DefineDic.getBalanceMode(mBean.getGs_balance_mode()) %>
                            </div><input type="hidden" id="mode<%=i+1 %>" name="mode" value="<%=mBean.getGs_balance_mode() %>">
                        </td>
                    </tr>
            <%} %>
<!-- 合计行 -->			
					<tr id='tr<%=mList.size()+1%>' class="bg_row_odd" height=20 >
						<td class=top align=middle colspan="9" nowrap>                         
                            <div align="right" class="txt_content"> 合计总价（元）：<div>
                        </td>
                        
                    	<td class=top align=middle colspan="5" nowrap>                         
                            <div align="left" class="txt_content" id="totalMoney">&nbsp;0.0000</div>
                        </td>
					</tr>	
											
                    </tbody> 
                </table>
            </td>
        </tr>
    </table>
    <p align="center">  
    </p>
</form>

<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td width=100% align=middle id="submitform">
			
			<input type="button" class="kuang" id='ccccc' value=" 确定 " onclick="openconfirm();return false;">
			<input type="button" class="kuang" id='bbbbb' value=" 取消 " onclick="window.close();">
			<input type='hidden' name='middleview'>
		</td>

	<tr>
</table>
</center>
<script language='javascript'>
	function formatordercount(obj){
	   obj.value = FormatNum2(obj);
	   getMoneyIndex(obj);
	}
	
	function openconfirm(val){
		if (!judgeStrLen("Textarea1")) return false;
			if(checkNoneableValue()){
				submitForm();		
			}
	}
	
	function middleviewsubmit(val){
		if(document.all.middleview.value == "T")
			<!--document.getElementById('aaaaa').disabled=true;-->
			document.getElementById('bbbbb').disabled=true;
			document.getElementById('ccccc').disabled=true;
			submitForm(val);
	}
	
	function keydown2(id){
		if(event.keyCode==13) {
			var obj = document.getElementById(id);
			if (obj.type =="radio")
			{
				obj.checked = true;
			}			
			obj.focus();
		}
	}
</script>
<script language='javascript'>
	function getMoneyIndex(obj)
	{
		var name = obj.name;
		var id = obj.id;
		var index = id.substring(name.length);
		getMoney(index);
	}
	function getMoney(index)
	{
		var ordercount = document.getElementById('ordercount' + index).value;
		var pricebuffer = document.getElementById('referenceprice' + index).innerText;
		if (ordercount == null || ordercount.length == 0 || isNaN(ordercount)) ordercount = 0;
		if (pricebuffer == null || pricebuffer.length == 0 || isNaN(pricebuffer)) pricebuffer = 0;
		var money = ordercount * pricebuffer ;
		if (money == null || money.length == 0 || isNaN(money)) money = 0;
		var obj = document.getElementById('money' + index);
		obj.innerText = money.toFixed(4);
		document.getElementById("moneybuffer" + index).value = money.toFixed(4);
		totalMoney();
	}
	function totalMoney()
	{
		var val = 0;
		var k = 0;
		for(k=1;k<=<%=mList.size()%>;k++)
		{
			var money = document.getElementById('moneybuffer' + k).value;
			if (money == null || money.length == 0 || isNaN(money)) money = 0;
			val = parseFloat(val) + parseFloat(money);
		}
		val = "" + val ;
		if (val == null || val.length == 0 || isNaN(val)) val = 0;
		var obj = document.getElementById('totalMoney');
		obj.value = val;
		val = FormatNum2(obj);
		obj.innerText = " " + val.toFixed(4) + " ";
		return true;
	}
	function judgeStrLen(name)
	{
		var str = document.getElementById(name).value;
		if (str == null || str.length == 0) return true;
		if (StrLen(str)><%=memoLen%>)
		{
			alert("备注长度不能超过<%=memoLen/2%>个汉字！");
			return false;
		}
		return true;
	}
    function window.onbeforeunload(){
        window.opener.location.reload();
    }
</script>
</body>
</html>